#include"Management.h"
#include<string>
#include<cstring>

Management::Management():m_capacity(10),m_size(0)
{
    Stu= new Student[m_capacity];
}

void Management::addStu(const Student& s)
{
    if(m_size>=m_capacity)
    {
        m_capacity *=2;
        Student *newP= new Student[m_capacity];
        for(int i=0; i< m_size; i++)
        {
            newP[i]=Stu[i];
        }
        delete []Stu;
        Stu= newP;
    }
    Stu[m_size++]= s;
}

void Management::Find(int id)
{
    for(int i=0; i<m_size; i++)
    {
        if(Stu[i].m_id==id)
        Stu[i].display();
    }
}

void Management::FindName(const char* name)
{
    for(int i=0; i<m_size; i++)
    {
        if(Stu[i].m_name==name)
        Stu[i].display();
    }
}

void Management::show()
{
    for(int i=0; i<m_size; i++)
    {
       Stu[i].display();
    }
}

Management::~Management()
{
    delete []Stu;
}